package org.kiwi.data.enums;

import org.springframework.util.Assert;

/**
 * Created by jack on 16/10/30.
 */
public enum LbType {
    RANDOM("random"), ROUNDROBIN("roundRobin");

    private String text;

    LbType(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

    public static LbType determineLbTypeByText(String text) {
        Assert.hasText(text, "text is required");

        for (LbType lbType : LbType.values()) {
            if (lbType.getText().equalsIgnoreCase(text))
                return lbType;
        }

        return ROUNDROBIN;
    }
}
